<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
  <head>
    <title></title>
    <meta charset="utf-8">
    <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" href="css/fonts/font-awesome.min.css">
    <link rel="stylesheet" href="css/ui-box.css">
    <link rel="stylesheet" href="css/ui-base.css">
    <link rel="stylesheet" href="css/ui-color.css">
    <link rel="stylesheet" href="css/appcan.icon.css">
    <link rel="stylesheet" href="css/appcan.control.css">
    <link rel="stylesheet" href="details/css/details.css">
    <!-- <link rel="stylesheet" href="chat/css/chat.css"> -->
    <style type="text/css">
    p {
        font-size: 0;
    }
    </style>
  </head>
  <body class="" ontouchstart>
    <div class="bc-bg" tabindex="0" data-control="PAGE" id="Page">
        <div class="uh ubb bc-border" data-control="HEADER" id="Header"
            style="background: #fff;border-bottom:1px solid #d6d6d6">
            <div class="ub">
                <div class="nav-btn" id="nav-left"
                    style="font-size: 1.5em;min-width: 0">
                    <div class="fa fa-angle-left" style="margin-left:0.5em;color:#666" onclick="edit();"></div>
                </div>
                <h1 class="ut ub-f1 ulev-3 ut-s tx-c" tabindex="0" style="color:#666">商品详情</h1>
                <div class="nav-btn icon-act" id="nav-right">
                    <div class="ub-img1 icon-forward ulev2" style="min-width: 1.4em;min-height: 1.4em;"></div>
                </div>
            </div>
        </div>
        <div class="" data-control="CONTENT" id="ScrollContent" style="margin-bottom: 3.2em">
           

        </div>
        <div class="ub ub-f1 bot_p">
            <div class="ub ub-ac ub-pc pos" onclick="cart();">
                <img src="css/icons/icon-cart-back.png" style="width: 1.4em;">
                <div class="ub-ac ub-pc ub abs">
                    <div class="ub-ac ub-pc ub abs_num" data-bind="text:infor"
                        id="carCont">0</div>
                </div>
            </div>
            <div class="ub-ac ub-pc ub-f1 bot_center" id="addCart">加入购物车</div>
            <div class="ub-ac ub-pc ub-f1 bot-right" id="buy">立即购买</div>
            <div class="ub-ac ub-pc ub-f1"
                style="padding: 1em 0;background:#BBB;color:#fff; text-align: center; display:none">抢光啦</div>
        </div>

        <!-- <div id="qwer"></div> -->

        <div class="utra" data-control="MASK" id="Mask"></div>
        <div class="sc-bg ubt ub ub-ver uhide" data-control="FOOTER"
            id="Footer_mask" style="background: #fff;font-size:0.9em">
           
        </div>

        <div class="sc-bg ub ub-ver uhide" data-control="FOOTER" id="Footer_share"
            style="background:#F3F3F3;font-size:0.9em;width: 100%;padding:1em 0;">
            <ul class="ub">
              
                <li class="ub ub-ver ub-ac umar-2" id="weixin">
                    <div class="ub-img accIcon2 umar-a-t1"></div>
                    <div class="ulev-1 umar-t-acc1 tx-c">微信好友</div>
                </li>
                <li class="ub ub-ver ub-ac umar-2" id="weiyou">
                    <div class="ub-img accIcon3 umar-a-t1"></div>
                    <div class="ulev-1 umar-t-acc1 tx-c">微信朋友圈</div>
                </li>

            </ul>
        </div>
    </div>
    <script src="js/appcan.js"></script>
    <script src="js/framework.js"></script>
    <script src="js/appcan.control.js"></script>
    <script src="js/template.import.js"></script>
    <script src="js/appcan.listview.js"></script>
    <script src="js/appcan.optionList.js"></script>
    <script src="details/js/appcan.slider.js"></script>
    <script src="js/appcan.tab.js"></script>
    <script src="js/appcan.treeview.js"></script>
    <script src="details/js/details.js"></script>
    <script src="details/js/ddd.js"></script>
    <script src="js/jquery-1.7.2.min.js"></script>
    <script src="js/jshint.js"></script>
    <script src="js/public_Install.js"></script>
    <script src="js/public_Util.js"></script>

    <script type="text/javascript" charset="utf-8">
        </script>
    <script>
    
        //分享商品链接
        function sessionUrl() {
            
            //判断当前设置是否安装微笑
            var info = uexWeiXin.registerApp("wx88e4a372bc6c2e02");
            var isLoad = uexWeiXin.isWXAppInstalled(); //是否安装
            //alert("是否安装" + isLoad);
            
            var img = appcan.locStorage.getVal("productImg");
            var name = appcan.locStorage.getVal("proName");
            var productId = appcan.locStorage.getVal("productId");            
            //alert("测试：" + img + "," + name + "," + productId);
            
            //分享信息和链接地址
            var JsonData = '{"thumbImg":' + img + ',"wedpageUrl":"http://yw2.wsh.chinatopv.com/topvmall/appproductInfo/share?PRODUCT_ID=' + productId + '","scene":1,"title":' + name + ',"description":' + name + '}';
            alert(JsonData);
            //appcan的分享Link事件
            uexWeiXin.shareLinkContent(JsonData, function(data) {
                alert("callback:" + JSON.stringify(data));
            });
            
        }
    
        function edit() {
            appcan.locStorage.setVal("locState", '');           
            appcan.locStorage.setVal("minDisCountPrice", 'null');
            //获取启动页广告链接状态  -6是启动页点击  其他正常返回上一页
            var StartThe = appcan.locStorage.getVal("StartThe");
            if( StartThe == -6 ){
                
                appcan.window.open({
                    name : "orderdetails",
                    dataType : 0,
                    aniId : 2,
                    data : "index2.html"
                });
            
            }else{
                
                appcan.window.close(-1);
             
            }
            appcan.locStorage.setVal("productId", 0);
            appcan.locStorage.setVal("StartThe", '');  
        }
        function cart() {
            var userId = appcan.locStorage.getVal("topvUserId");
            if (userId == null) {
                appcan.window.confirm({
                    title : '提示',
                    content : '请登录后进行该操作',
                    buttons : [ '马上登录', '暂不登录' ],
                    callback : function(err, data, dataType, optId) {
                        if (data == "0") {
                            appcan.window.open({
                                name : "loginn",
                                dataType : 0,
                                aniId : 2,
                                data : "login.html"
                            });
                        } else if (data == "1") {
                        }
                    }
                });
            } else {
                appcan.window.open({
                    name : "cart",
                    dataType : 0,
                    aniId : 2,
                    data : "cart.html"
                });
            }
        }
    
        window.uexOnload = function() {
            appcan.window.setWindowScrollbarVisible(0);
            appcan.window.disableBounce();
            showProDetails();
            var isQhide = appcan.locStorage.getVal("isQhide");
            if (isQhide == 1) {
                $("#addCart").removeAttr('onclick');
                $("#buy").removeAttr('onclick');
            }
            appcan.window.subscribe("reloadCartcount", function(msg) {
                initCarcount();
            });
        }
    
        function showProJsonSuccess(opid, status, result, requesCode) {
            if (requesCode == 200) {
                if (status == 1) {
                    //关闭请求
                    uexXmlHttpMgr.close(1);
                    //将返回的json字符串转换为JSON对象
                    var temp;
                    try {
                        temp = eval('(' + result + ')');
                    } catch (err) {
                        openErrorPage("", "SERVERERROR");
                        return false;
                    }
                    //session 过期后，判断重新登录
                    if (temp.errMgt == 1) {
    
                        appcan.window.publish('index', "") ;
                        resetLogin("login" + random, "index.html", 0);
    
                    }
                    var proObj = temp.value.pd;
                    if (typeof (proObj) == "undefined" || proObj == null || proObj == "") {
                        return false;
                    }
                    appcan.locStorage.setVal("proObj", proObj);
                    showProductData();
                }
            } else {
                openErrorPage("", requesCode);
            }
            //购物车数量
            initCarcount();
        }
        
        //显示购物车数量 
        function initCarcount() {
            var userId = appcan.locStorage.getVal("topvUserId");
            if (userId == null) {
                return false;
            }
            newDrugUrl = urlPrefix + "/appcar/carCount.do";
            uexXmlHttpMgr.onData = getCarcountSuccess;
            uexXmlHttpMgr.open(60, "POST", newDrugUrl, "");
            uexXmlHttpMgr.setPostData(60, 0, "userId", userId);
            uexXmlHttpMgr.send(60);
        }
        
        function getCarcountSuccess(opid, status, result, requesCode) {
            if (requesCode == 200) {
                if (status == 1) {
                    //关闭请求
                    uexXmlHttpMgr.close(60);
                    //将返回的json字符串转换为JSON对象
                    var temp;
                    try {
                        temp = eval('(' + result + ')');
                    } catch (err) {
                        openErrorPage("", "SERVERERROR");
                        return false;
                    }
                    //session 过期后，判断重新登录
                    if (temp.errMgt == 1) {
    
                        appcan.window.publish('index', "") ;
                        resetLogin("login" + random, "index.html", 0);
    
                    }
                    if (temp.code == "0") {
                        var len = temp.count;
                        $("#carCont").html(len);
                    }
    
                }
            } else {
                openErrorPage("", requesCode);
            }
        }
        
        function showProductData() {
            var proObj = appcan.locStorage.getVal("proObj");
            var productDetail = eval('(' + proObj + ')');
            var productDe = productDetail.product;
            var productDetails = productDe ? productDe : "";
    
            //商品介绍
            var intro = productDetails ? productDetails.intro.replace(/\@topvProject/g, imgPrefix) : "";
            //规格参数
            var paraArr = productDetail.parameter == "0" ? "" : productDetail.parameter;
            //图片
            appcan.locStorage.setVal("productImg", productDetail.pImg);
            //判断是否是限时特卖，是否显示时间
            // productDetails.tagId = 1;
            //   var pricePro = (productDetails.price)?(productDetails.price).toFixed(2):"";
    
    
            var price_repex = 0;
    
            //获取点击事件   1是专场  6是发现    默认是首页进入详情
            var state = appcan.locStorage.getVal("locState");
            //获取商品原价
            var pricePro = (productDetails.price) ? (productDetails.price).toFixed(2) : "";
            //获取折扣率   
            var minDisCountPrice = appcan.locStorage.getVal("minDisCountPrice");
    
            if (state == 1) {
    
                var bminDisCount = (pricePro * (minDisCountPrice / 10)).toFixed(2);
    
            } else if (state == 6) {
    
                var bminDisCount = (productDetails.price) ? (productDetails.price).toFixed(2) : "";
    
            } else {
                //获取商品折扣价  
                var favorablePrice = productDetails.favorablePrice;
                //判断 折扣率，商品折扣价 是否为空，6 发现是不打折区域
                if (favorablePrice == null && minDisCountPrice == null) {
    
                    var bminDisCount = (productDetails.price) ? (productDetails.price).toFixed(2) : "";
    
                } else if (favorablePrice == null && minDisCountPrice == "null") {
    
                    var bminDisCount = (productDetails.price) ? (productDetails.price).toFixed(2) : "";
    
                } else {
    
                    var bminDisCount = productDetails.favorablePrice ? productDetails.favorablePrice : "";
    
                }
            }
    
            //分享佣金  
            pricePro = "" + pricePro;
            var p_r_t = productDetail.price_repex;
            if(p_r_t == undefined || p_r_t == "" || p_r_t == "null"){
                p_r_t = 0;
            }
            price_repex = parseFloat(pricePro) * (parseFloat(p_r_t) / 100);
            //price_repex = (price_repex / 2).toFixed(2);
            price_repex = price_repex.toFixed(2);
    
            appcan.locStorage.setVal("price_repex", price_repex);
            /*
                       if(favorableP ==""){
                            favorableP = "" + pricePro;
                              price_repex = parseFloat(favorableP)*(parseFloat(productDetail.price_repex)/100);
                             price_repex=(price_repex/2).toFixed(2);
                             if(minDisCountPrice!=null&&minDisCountPrice!=''&&minDisCountPrice!=undefined&&minDisCountPrice!='undefined'){
                                   favorableP=favorableP*(parseFloat(minDisCountPrice)/10);
                             }
                            pricePro="";
                           
                            
                        }else{
                            pricePro = "" + pricePro;
                             price_repex = parseFloat(pricePro)*(parseFloat(productDetail.price_repex)/100);
                             price_repex=(price_repex/2).toFixed(2);
                           
                        }*/
    
            if (proObj != null && proObj != "" && typeof (proObj) != "undefined") {
                var prohtml = "";
                prohtml += "<div class=''><div class='ub ub-ver'><div id='' class='ub-fh t-bla uof'><div id='slider' class='slider'></div></div><div class='ub-fh t-bla uof' style='position:absolute;top:0;display:none;'><img style='width:100%;height:23em' src='category/css/myImg/soldout.png'/></div></div>";
                if (productDetails ? productDetails.tagId == 1 : false) {
                    prohtml += "<div class='ub ub-f1 deta mubanbg'><div class='ub ub-f1'>限时特卖</div><div class='ub'>距结束仅剩";
                    prohtml += "<span class='ulev-tit t-b'><s class='hand hand-h'><s class='digital'>00</s></s>:";
                    prohtml += "<s class='hand hand-m'><s class='digital'>32</s></s>:";
                    prohtml += "<s class='hand hand-s'><s class='digital'>34</s></s></span></div></div>";
                }
                var priceStyle = "";
                if (pricePro != null && pricePro != '' && pricePro != undefined && pricePro != 'undefined') {
                    priceStyle = "￥";
                }
                appcan.locStorage.setVal("proName", productDetails.name);
                prohtml += "<div class='ub ub-ver uinn-a7 sc-bg1'><div class='ubb bc-border'><div class='ub'>";
                prohtml += "<div class='ub-f1 ulev-app2 line-hei uh-de2 uof'>" + productDetails.name + "</div></div>";
                if (state == 6) {
    
                    prohtml += "<div class='ub ub-ae umar-t'><div class='sc-text-warn  ulev2'>" + "￥" + bminDisCount + "</div><span class='utx-de t-bla-de2 ulev-4'></span><div class='shareval' id='share'>分红包" + price_repex + "</div></div></div></div>";
    
                } else if (favorablePrice == null && minDisCountPrice == null) {
    
                    prohtml += "<div class='ub ub-ae umar-t'><div class='sc-text-warn  ulev2'>" + "￥" + bminDisCount + "</div><span class='utx-de t-bla-de2 ulev-4'></span><div class='shareval' id='share'>分红包" + price_repex + "</div></div></div></div>";
    
                } else if (favorablePrice == null && minDisCountPrice == "null") {
    
                    prohtml += "<div class='ub ub-ae umar-t'><div class='sc-text-warn  ulev2'>" + "￥" + bminDisCount + "</div><span class='utx-de t-bla-de2 ulev-4'></span><div class='shareval' id='share'>分红包" + price_repex + "</div></div></div></div>";
    
                } else {
    
                    prohtml += "<div class='ub ub-ae umar-t'><div class='sc-text-warn  ulev2'>" + "￥" + bminDisCount + "</div><span class='utx-de t-bla-de2 ulev-4'>" + priceStyle + pricePro + "</span><div class='shareval' id='share'>分红包" + price_repex + "</div></div></div></div>";
    
                }
                prohtml += "<ul ontouchstart='appcan.touch(" + "'btn-act'" + ")' class='ub ub-ver bc-text sc-bg1 uinn-a1'>";
                prohtml += "<li class='uinn-a14 sc-text-warn coupon' id='getCoupon'></li></ul></div></div>";
                prohtml += "<div class='ub uinn-a7 sc-bg1 m-t'><div class='ub ub-f1' id='guige'>规格和数量</div>";
                prohtml += "<div class='ub fa fa-angle-right'></div></div>";
                prohtml += "<div class='ub m-t ubt bc-border' style='background: #fff;'>";
                prohtml += "<ul class='ub ub-f1 padd' style='border-bottom:1px solid #EEEEEE;'>";
                prohtml += "<li class='b_bt' onclick='sh_xq(1,this)' id='listt1'>商品介绍</li>";
                // if(paraArr.length>0){
                prohtml += "<li class='' onclick='sh_xq(2,this)' id='listt2'>规格参数</li>";
                // }
                prohtml += "</ul></div>";
                prohtml += "<div class='ub-ver' id='more1' style='background: #fff;'>" + intro + "</div>";
                prohtml += "<div class='b-ver' id='more2' style='display: none;background: #fff;'>";
                prohtml += "<div class='ub ub-ver mubanfont'>";
                if (paraArr.length > 0) {
                    $.each(paraArr, function(i, item) {
                        prohtml += "<div class='ub uinn-a9 b-t'><div class='ub-f1 w30'>" + item.field + "</div><div class='ub-f2 w70'>" + item.record + "</div></div>"
                    });
                // }else{
                // $("#listt2").hide();
                }
                prohtml += "</div>";
                prohtml += "<img src='" + imgPrefix + productDetails.img + "' style='width:100%'></div></div>";
            } else {
                prohtml += "<div class=''>无相关数据</div>";
            }
            $("#ScrollContent").html(prohtml);
            var imgArr = $("#more1 p img");
            if (imgArr.length > 0) {
                $.each(imgArr, function(i, item) {
                    item.style.width = "100%";
                });
            }
            var productHtml = "";
            productHtml += "<div class='ub ub-ver mh' style='padding:1em;'><div class='ub ubb bc-border uinn-b'>";
            productHtml += "<div class='ub imghw'><img src='" + imgPrefix + productDetails.img + "' style='width:100%;border-radius:0.3em' id='skuImg'></div>";
            productHtml += "<div class='ub ub-f1'><ul style='margin-left:1.2em'><li style='color:#FF0000' id='proPrice'>价格：￥" + bminDisCount + "</li>";
            productHtml += "<li style='margin-top:1.5em'>请选择规格</li></ul></div>";
            productHtml += "<div id='close' class='ub fa fa-times-circle-o' style='width: 1em;font-size:1.5em;color:#3C3939'></div></div>";
            productHtml += "<div class='ub ub-ver' id='panelSku'>";
            var arrSku = productDetail.spList;
            var arr0 = [];
            var arr1 = [];
            var arr2 = [];
            var arr3 = [];
            for (var i = 0; i < arrSku.length; i++) {
                var a = arrSku[i].skuValue;
                a = a ? a : "";
                if (a[0] != null && typeof (a[0]) != "undefined") {
                    arr0.push(a[0]);
                }
                if (a[1] != null && typeof (a[1]) != "undefined") {
                    arr1.push(a[1]);
                }
                if (a[2] != null && typeof (a[2]) != "undefined") {
                    arr2.push(a[2]);
                }
                if (a[3] != null && typeof (a[3]) != "undefined") {
                    arr[3].push(a[3]);
                }
            }
            if (arr0.length > 0) {
                var map = getMap();
                $.each(arr0, function(i, item) {
                    if (!map[item.id]) {
                        map.put(item.id, item);
                    }
                });
                var arr = [];
                for (var key in map) {
                    arr.push(map[key]);
                }
                var canshu = arr[0].skuValueName;
                productHtml += "<div class='ub ub-ver pad ubb bc-border' style='font-size:1em'><div class='ub uinn-a14'>" + canshu + "</div><div class='ub-f1' name='0'>";
                $.each(arr, function(i, item) {
                    if (item.id != null && typeof (item.id) != "undefined") {
                        productHtml += "<div class='uinn tag' name='0' value='" + item.id + "' onclick='changeGuige(this);'>" + item.typeValue + "</div>";
                    }
                });
                productHtml += "</div></div>";
            }
            if (arr1.length > 0) {
                var map = getMap();
                $.each(arr1, function(i, item) {
                    if (!map[item.id]) {
                        map.put(item.id, item);
                    }
                });
                var arr = [];
                for (var key in map) {
                    arr.push(map[key]);
                }
                var canshu = arr[0].skuValueName;
                productHtml += "<div class='ub pad ub-ver ubb bc-border' style='font-size:1em'><div class='ub uinn-a14'>" + canshu + "</div><div class='ub-f1' name='0'>";
                $.each(arr, function(i, item) {
                    if (item.id != null && typeof (item.id) != "undefined") {
                        productHtml += "<div class='uinn tag' name='0' value='" + item.id + "' onclick='changeGuige(this);'>" + item.typeValue + "</div>";
                    }
                });
                productHtml += "</div></div>";
            }
            if (arr2.length > 0) {
                var map = getMap();
                $.each(arr2, function(i, item) {
                    if (!map[item.id]) {
                        map.put(item.id, item);
                    }
                });
                var arr = [];
                for (var key in map) {
                    arr.push(map[key]);
                }
                var canshu = arr[0].skuValueName;
                productHtml += "<div class='ub pad ub-ver  ubb bc-border' style='font-size:1em'><div class='ub uinn-a14'>" + canshu + "</div><div class='ub-f1' name='0'>";
                $.each(arr, function(i, item) {
                    if (item.id != null && typeof (item.id) != "undefined") {
                        productHtml += "<div class='uinn tag' name='0' value='" + item.id + "' onclick='changeGuige(this);'>" + item.typeValue + "</div>";
                    }
                });
                productHtml += "</div></div>";
            }
            if (arr3.length > 0) {
                var map = getMap();
                $.each(arr3, function(i, item) {
                    if (!map[item.id]) {
                        map.put(item.id, item);
                    }
                });
                var arr = [];
                for (var key in map) {
                    arr.push(map[key]);
                }
                var canshu = arr[0].skuValueName;
                productHtml += "<div class='ub pad'>" + canshu + "</div><div class='ub' style='font-size:1em'><div class='ub-f1' name='0'>";
                $.each(arr, function(i, item) {
                    if (item.id != null && typeof (item.id) != "undefined") {
                        productHtml += "<div class='uinn tag' name='0' value='" + item.id + "' onclick='changeGuige(this);'>" + item.typeValue + "</div>";
                    }
                });
                productHtml += "</div></div>";
            }
            productHtml += "<div class='ub pad ubb bc-border'><div class='ub-f1 uinn-a14'>数量</div>";
            productHtml += "<div class='uwh-pSC1 tx-c uba bc-border uc-a-app1 t-bla mar-ar1' id='minNum'>-</div>";
            productHtml += "<div class='uba uc-a-app1 bc-border uinput uwh-pSC2 mar-ar1 c-wh'>";
            productHtml += "<input type='text' readonly='readonly' value='1' class='uinn-pSC3 t-bla tx-c' id='number'></div>";
            productHtml += "<div class='uwh-pSC1 tx-c uba bc-border uc-a-app1 t-bla' id='addNum'>+</div></div></div></div>";
            productHtml += "<div class='ub ub-ac ub-pc enter' onclick='saveSure();' id='saveSure'>确认</div>";
            $("#Footer_mask").html(productHtml);         
            //没有规格时去掉‘请选择规格’
            var num = $("#panelSku").find("div[class='ub pad']").length - 1;
            if (num < 1) {
                $("#proPrice").next().html("");
            }
            //商品常见问题
            $("#more1").append("<p><img src='details/css/myImg/changj.jpg' class='J-mer-bigImg' data-original='' style='border: 0px none; vertical-align: top; display: inline; width: 100%;'></p>");
            goodsImg();
    
    
            appcan.locStorage.setVal("locState", '');
            appcan.locStorage.setVal("minDisCountPrice", 'null');
    
        }
        //获取商品详情
        function showProDetails() {
  
            var productId = appcan.locStorage.getVal("productId");
         
            newDrugUrl = urlPrefix + "/appproductInfo/info.do";
            uexXmlHttpMgr.onData = showProJsonSuccess;
            uexXmlHttpMgr.open(1, "POST", newDrugUrl, "");
            uexXmlHttpMgr.setPostData(1, 0, "PRODUCT_ID", productId);
            uexXmlHttpMgr.send(1);
        }
    
        function goodsImg() {
            //商品详情图片轮播
            var slider = appcan.slider({
                selector : '#slider',
                aspectRatio : 9 / 16,
                hasLabel : false,
                index : 0,
                hasIndicator : false
            // auto:3000
            });
            var Img = appcan.locStorage.getVal("productImg");
            var arrImgs = eval('(' + Img + ')');
            var imgA = [];
            $.each(arrImgs, function(i, item) {
                var map = getMap();
                map.put("img", imgPrefix + item.img);
                imgA.push(map);
            });
            slider.set(imgA);
            slider.on("clickItem", function(index, data) {
                console.log(index, data);
            });
            var startX,
                startY,
                endX,
                endY,
                nowh;
            var sliderH = parseInt($("body").css("font-size")) * 22.5;
            var hei = $("#slider").css("height", sliderH + "px");
            $("#slider").on("touchstart", function(evt) {
                startX = evt.originalEvent.changedTouches[0].pageX;
                startY = evt.originalEvent.changedTouches[0].pageY;
                nowh = parseInt($(".slider-group").css("height"));
            });
            $("#slider").on("touchmove", function(evt) {
                endX = evt.originalEvent.changedTouches[0].pageX;
                endY = evt.originalEvent.changedTouches[0].pageY;
                moveX = startX - endX > 0 ? startX - endX : endX - startX;
                moveY = startY - endY > 0 ? startY - endY : endY - startY;
                var chaY = endY - startY;
                item = 0;
                if (moveY > moveX) {
                    if (chaY > 0) {
                        moveY > 100 ? moveY = 300 : moveY = moveY;
                        $("#slider").css("height", sliderH + moveY + "px")
                        $("#slider").css("transition", "all 0.6s");
                        item = 1 + moveY / (nowh + moveY);
                        $(".slider-item").css("transform", "scaleZ(" + item + ")");
                        $(".slider-item").css("transition", "all 0.6s");
                    }
                } else {
                    evt.preventDefault();
                }
    
            });
            $("#slider").on("touchend", function() {
                $("#slider").css("height", sliderH + "px");
                $(".slider-item").css("transform", "scale(1)")
            // $(document).off("touchmove");
            });
        }
        //改变规格
        function changeGuige(obj) {
            cencelDisableClickMethod("saveSure");
            var name = $(obj).parent().attr("name");
            if (name == "0") {
                $(obj).parent().attr("name", "1");
            }
            var al = $(obj).siblings();
            if (al.length > 0) {
                $.each(al, function(i, item) {
                    item.style.borderColor = "";
                    var name = $(item).attr("name");
                    if (name == "1") {
                        $(item).attr("name", "0");
                    }
                });
            }
            obj.style.borderColor = "red";
            $(obj).attr("name", "1");
            var a = obj.innerText;
            var cont = $("li[style='margin-top:1.5em']").html();
            var panel = $("#panelSku").find("div[class='uinn tag']");
            var allcont = "";
            $.each(panel, function(i, item) {
                var name = $(item).attr("name");
                if (name == "1") {
                    allcont += $(item).html() + " ";
                }
            });
            $("li[style='margin-top:1.5em']").html("已选择:" + allcont);
            //判断循环次数
            var nameList = $("#panelSku").find("div[class='uinn tag']");
            var count = 0;
            $.each(nameList, function(i, item) {
                var name = $(item).attr("name");
                if (name == "1") {
                    count++;
                }
            });
            var totalCount = $("#panelSku").find("div[class='ub pad']").length - 1;
            if (count == totalCount) {
                //根据属性id查询商品skuid
                getSkuIdByIds();
            }
        }
        //获取sku的价格，图片等
        function getSkuInfo() {
            var skuId = $("#proPrice").attr("value");
            newDrugUrl = urlPrefix + "/appproductInfo/InfoImg.do";
            uexXmlHttpMgr.onData = getSkuSuccess;
            uexXmlHttpMgr.open(1001, "POST", newDrugUrl, "");
            uexXmlHttpMgr.setPostData(1001, 0, "skuId", skuId);
            uexXmlHttpMgr.send(1001);
        }
        function getSkuSuccess(opid, status, result, requesCode) {
            if (requesCode == 200) {
                if (status == 1) {
                    //关闭请求
                    uexXmlHttpMgr.close(1001);
                    //将返回的json字符串转换为JSON对象
                    var temp;
                    try {
                        temp = eval('(' + result + ')');
                    } catch (err) {
                        openErrorPage("", "SERVERERROR");
                        return false;
                    }
                    //session 过期后，判断重新登录
                    if (temp.errMgt == 1) {
    
                        appcan.window.publish('index', "");
                        resetLogin("login" + random, "index.html", 0);
    
                    }
                    var data = temp.value;
                    var price = data.PRICE;
    
                    if (price != null && price != "" && typeof (price) != "undefined") {
                        price = price.toFixed(2);
                        $("#proPrice").html("价格：￥" + price);
                    }
                    var img = data.pd ? data.pd : "";
                    var Imgs = img.IMG ? img.IMG : "";
                    if (Imgs != null && Imgs != "" && typeof (Imgs) != "undefined") {
                        $("#skuImg").attr("src", imgPrefix + Imgs);
                    }
                }
            } else {
                openErrorPage("", requesCode);
            }
        }
        //确认
        function saveSure() {
            if (disableClick) {
                return false;
            }
            var userId = appcan.locStorage.getVal("topvUserId");
            var choo = appcan.locStorage.getVal("cartAndBuy");
            if (userId == null) {
    
               cart();
            } else if (choo == null) {
                var panelLength = $("#panelSku").find("div[class='ub pad']").length - 1;
                var panelSku = $("#panelSku").find("div[class='uinn tag']");
                var count = 0;
                $.each(panelSku, function(i, item) {
                    var name = $(item).attr("name");
                    if (name == "1") {
                        count++;
                    }
                });
                
                console.log(count)
                if (panelLength == count) {
                    var number = $("#number").attr("value");
                    var unitPrice = $("#proPrice").html();
                    var img = $("#skuImg").attr("src");
                    var skuInfo = $("#proPrice").next().html(); //商品规格
                    var skuId = $("#proPrice").attr("value");
                    if (skuId != "" && skuId != null) {
                        skuId = skuId;
                    } else {
                        var proObj = appcan.locStorage.getVal("proObj");
                        var productDetail = eval('(' + proObj + ')');
                        skuId = productDetail.product.skuId;
                    }
                    appcan.locStorage.getVal("productId");
                    appcan.locStorage.setVal("proNumberPrice", number + "," + unitPrice + "," + img + "," + skuInfo + "," + skuId);
                    appcan.window.open({
                        name : "orderdetails",
                        dataType : 0,
                        aniId : 2,
                        data : "orderdetails/orderdetails.html"
                    });
                } else {
                    appcan.window.openToast({
                        msg : '请选择规格',
                        duration : 2000,
                        position : 5,
                        type : 0
                    });
                }
    
                appcan.window.publish('reloadCartcount', "") ;
    
            } else {
                if (choo == "0") { //加入购物车
                    var panelLength = $("#panelSku").find("div[class='ub pad']").length - 1;
                    var panelSku = $("#panelSku").find("div[class='uinn tag']");
                    var count = 0;
                    $.each(panelSku, function(i, item) {
                        var name = $(item).attr("name");
                        if (name == "1") {
                            count++;
                        }
                    });
                    if (panelLength == count) {
                        var skuId = $("#proPrice")[0].getAttribute("value");
                        if (skuId != "" && skuId != null) {
                            skuId = skuId;
                        } else {
                            var proObj = appcan.locStorage.getVal("proObj");
                            var productDetail = eval('(' + proObj + ')');
                            skuId = productDetail.product.skuId;
                        }
                        var proObj = appcan.locStorage.getVal("proObj");
                        var productObj = eval('(' + proObj + ')');
                        // var userId = 1;
                        var userId = appcan.locStorage.getVal("topvUserId");
                        var productId = productObj.id;
                        var img = $("#skuImg").attr("src");
                        var price = $("#proPrice").html().split("￥")[1];
                        var name = escape(productObj.product.name);
                        var skuInfo = $("#proPrice").next().html() ? $("#proPrice").next().html() : "";
                        var proNumber = $("#number").attr("value");
                        newDrugUrl = urlPrefix + "/appcar/addCar.do";
                        uexXmlHttpMgr.onData = addCartSuccess;
                        uexXmlHttpMgr.open(200, "POST", newDrugUrl, "");
                        uexXmlHttpMgr.setPostData(200, 0, "userId", userId);
                        uexXmlHttpMgr.setPostData(200, 0, "productId", productId);
                        uexXmlHttpMgr.setPostData(200, 0, "skuId", skuId);
                        uexXmlHttpMgr.setPostData(200, 0, "img", img);
                        uexXmlHttpMgr.setPostData(200, 0, "price", price);
                        uexXmlHttpMgr.setPostData(200, 0, "name", name);
                        uexXmlHttpMgr.setPostData(200, 0, "skuInfo", skuInfo);
                        uexXmlHttpMgr.setPostData(200, 0, "proNumberPrice", proNumber);
                        uexXmlHttpMgr.setPostData(200, 0, "proNumber", proNumber);
                        uexXmlHttpMgr.send(200);
    
                        appcan.locStorage.setVal("number", proNumber);
    
                    } else {
                        appcan.window.openToast({
                            msg : "请选择规格",
                            duration : 2000,
                            position : 5,
                            type : 0
                        });
                        return false;
                    }
    
                } else if (choo == "1") { //立即购买
                    var panelLength = $("#panelSku").find("div[class='ub pad']").length - 1;
                    var panelSku = $("#panelSku").find("div[class='uinn tag']");
                    var count = 0;
                    $.each(panelSku, function(i, item) {
                        var name = $(item).attr("name");
                        if (name == "1") {
                            count++;
                        }
                    });
                    if (panelLength == count) {
                        var number = $("#number").attr("value");
                        var unitPrice = $("#proPrice").html();
                        var img = $("#skuImg").attr("src");
                        var skuInfo = $("#proPrice").next().html(); //商品规格
                        var skuId = $("#proPrice").attr("value");
                        if (skuId != "" && skuId != null) {
                            skuId = skuId;
                        } else {
                            var proObj = appcan.locStorage.getVal("proObj");
                            var productDetail = eval('(' + proObj + ')');
                            skuId = productDetail.product.skuId;
                        }
                        appcan.locStorage.getVal("productId");
                        appcan.locStorage.setVal("proNumberPrice", number + "," + unitPrice + "," + img + "," + skuInfo + "," + skuId);
                        appcan.window.open({
                            name : "orderdetails",
                            dataType : 0,
                            aniId : 2,
                            data : "orderdetails/orderdetails.html"
                        });
                    } else {
                        appcan.window.openToast({
                            msg : '请选择规格',
                            duration : 2000,
                            position : 5,
                            type : 0
                        });
                    }
    
                    appcan.window.publish('reloadCartcount', "") ;
                }
    
            }
    
    
        }
        //加入购物车
        function addCartSuccess(opid, status, result, requesCode) {
            if (requesCode == 200) {
                if (status == 1) {
                    uexXmlHttpMgr.close(200);
                    var temp;
                    try {
                        temp = eval('(' + result + ')');
                    } catch (err) {
                        openErrorPage("", "SERVERERROR");
                        return false;
                    }
                    //session 过期后，判断重新登录
                    if (temp.errMgt == 1) {
                        appcan.window.publish('index', "") ;
                        resetLogin("login" + random, "index.html", 0);
                    }
                    var data = temp.code;
                    if (data == "0") {
                        $("#Mask").removeClass("active");
                        $("#Footer_mask").addClass('uhide');
                        // setTimeout(function() {
                        // self.removeClass("show");
                        // },
                        // 1);
                        appcan.window.openToast({
                            msg : "加入购物车成功",
                            duration : 2000,
                            position : 5,
                            type : 0
                        });
                        appcan.window.publish("reloadCartcount", "");
                    // var count = $("#carCont").html();
                    // $("#carCont").html(parseInt(count)+1);
                    } else {
                        appcan.window.openToast({
                            msg : "加入购物车失败",
                            duration : 2000,
                            position : 5,
                            type : 0
                        });
                    }
                }
            } else {
                openErrorPage("", requesCode);
            }
        }
    
        //根据属性ids查询skuid
        function getSkuIdByIdLoad(productId) {
            var panel = $("#panelSku").find("div[class='uinn tag']");
            if (panel.length > 0) {
                var skuValues = "";
                $.each(panel, function(i, item) {
                    var name = $(item).attr("name");
                    skuValues += item.getAttribute("value") + ",";
                });
                newDrugUrl = urlPrefix + "/appproductInfo/getSkuInfo.do";
                uexXmlHttpMgr.onData = getSkuIdSuccessLoad;
                uexXmlHttpMgr.open(100, "POST", newDrugUrl, "");
                uexXmlHttpMgr.setPostData(100, 0, "PRODUCT_ID", productId);
                uexXmlHttpMgr.setPostData(100, 0, "skuValues", skuValues);
                uexXmlHttpMgr.send(100);
            }
        }
    
        function getSkuIdSuccessLoad(opid, status, result, requesCode) {
            if (requesCode == 200) {
                if (status == 1) {
                    uexXmlHttpMgr.close(100);
                    var temp;
                    try {
                        temp = eval('(' + result + ')');
                    } catch (err) {
                        openErrorPage("", "SERVERERROR");
                        return false;
                    }
                    //session 过期后，判断重新登录
                    if (temp.errMgt == 1) {
    
                        appcan.window.publish('index', "") ;
                        resetLogin("login" + random, "index.html", 0);
    
                    }
                    var data = temp.value;
                    var sku = data.sku ? data.sku : "";
                    var state = sku.state ? sku.state : "";
                    if (data.msg == "1" && state == "2") {
                        var id = data.sku.id;
                        //将skuid保存在proPrice中
                        $("#proPrice").attr("value", id);
                        //通过skuId查询商品的价格图片等
                        getSkuInfo();
                    } else if (data.msg == "1" && state == "4") {
                        appcan.window.openToast({
                            msg : "抢光啦",
                            duration : 2000,
                            position : 5,
                            type : 0
                        });
                    } else {
    
    
                    }
    
                }
            } else {
                openErrorPage("", requesCode);
            }
        }
    
        //根据属性ids查询skuid
        function getSkuIdByIds() {
            var productId = appcan.locStorage.getVal("productId");
            var panel = $("#panelSku").find("div[class='uinn tag']");
            if (panel.length > 0) {
                var skuValues = "";
                $.each(panel, function(i, item) {
                    var name = $(item).attr("name");
                    if (name == "1") {
                        skuValues += item.getAttribute("value") + ",";
                    }
                });
                newDrugUrl = urlPrefix + "/appproductInfo/getSkuInfo.do";
                uexXmlHttpMgr.onData = getSkuIdSuccess;
                uexXmlHttpMgr.open(100, "POST", newDrugUrl, "");
                uexXmlHttpMgr.setPostData(100, 0, "PRODUCT_ID", productId);
                uexXmlHttpMgr.setPostData(100, 0, "skuValues", skuValues);
                uexXmlHttpMgr.send(100);
            }
        }
        function getSkuIdSuccess(opid, status, result, requesCode) {
            if (requesCode == 200) {
                if (status == 1) {
                    uexXmlHttpMgr.close(100);
                    var temp;
                    try {
                        temp = eval('(' + result + ')');
                    } catch (err) {
                        openErrorPage("", "SERVERERROR");
                        return false;
                    }
                    //session 过期后，判断重新登录
                    if (temp.errMgt == 1) {
    
                        appcan.window.publish('index', "") ;
                        resetLogin("login" + random, "index.html", 0);
    
                    }
                    var data = temp.value;
                    var sku = data.sku ? data.sku : "";
                    var state = sku.state ? sku.state : "";
                    if (data.msg == "1" && state == "2") {
                        var id = data.sku.id;
                        //将skuid保存在proPrice中
                        $("#proPrice").attr("value", id);
    
                        var fav = sku.favorablePrice;
                        var price = sku.price;
    
                        var proObj = appcan.locStorage.getVal("proObj");
                        var productDetail = eval('(' + proObj + ')');
                        var productDe = productDetail.product;
                        var productDetails = productDe ? productDe : "";
                        var state = appcan.locStorage.getVal("locState");
                        var minDisCountPrice = appcan.locStorage.getVal("minDisCountPrice");
    
                        if (state == 1) {
                            if (minDisCountPrice > 0 && minDisCountPrice != '') {
                                var bminDisCount = (price * (minDisCountPrice / 10)).toFixed(2);
                                $("#proPrice").html("价格：￥" + bminDisCount);
                            } else {
                                $("#proPrice").html("价格：￥" + price);
                            }
                        } else {
    
                            if (fav != null && fav != "") {
                                $("#proPrice").html("价格：￥" + fav);
                            } else {
                                $("#proPrice").html("价格：￥" + price);
                            }
    
                        }
    
                    //通过skuId查询商品的价格图片等
                    //getSkuInfo();
                    } else if (data.msg == "1" && state == "4") {
                        appcan.window.openToast({
                            msg : "抢光啦",
                            duration : 2000,
                            position : 5,
                            type : 0
                        });
                        disableClickMethod("saveSure");
                        return false;
                    } else if (data.msg = "1" && sku.state == "0") {
                        appcan.window.openToast({
                            msg : "产品规格未上架",
                            duration : 2000,
                            position : 5,
                            type : 0
                        });
                        disableClickMethod("saveSure");
                        return false;
                    //getSkuInfo();
                    }
    
                }
            } else {
                openErrorPage("", requesCode);
            }
        }
    </script>
  </body>
</html>